"""
- Barrier => 使多个线程在指定点同步
barrier.wait() # 等待所有的线程到达
"""
import time
import threading
# 创建需要3个线程屏障
barrier = threading.Barrier(3)
def team_member(name):
    print(f"{name}出发前集合点")
    time.sleep(1)
    print(f"{name}达到集合点等待")
    barrier.wait() # 等待所有队员到达
    print(f"{name}继续前进")
if __name__ == '__main__':
    mumbers = ["小明","小红","小刚"]
    threads = []
    for name in mumbers:
        t = threading.Thread(target=team_member,args=(name,))
        t.start()
        threads.append(t)
    for t in threads:
        t.join()
    print("所有队员完成任务")
